package junior.Recursion递归;


/**
 递归算法
 * */
public class 猴子爬山 {
    public static void main(String[] args) {
        猴子爬山 mcm = new 猴子爬山();
        long startTime = System.currentTimeMillis();
        int sums = mcm.fun(7);
        long endTime = System.currentTimeMillis();
        System.out.println(sums);
        System.out.println("执行时间："+(endTime-startTime)+"ms");
    }

/**
递归算法求解猴子爬山
*/
    public int fun(int steps){
        System.out.println("fun( "+steps+" )");
        if(steps == 1 || steps == 2)
            return 1;
        if (steps == 3)
            return 2;
        else
            return fun(steps-1)+fun(steps-3);
    }
}
